package compilador;

import java_cup.runtime.*;
import javax.swing.*;
import java.util.*;
import compilador.*;
%%
%class Yylex
%cup
%line
%full
%unicode
%ignorecase
%char

%{
  public String sourceFilename;
 StringBuffer string = new StringBuffer();
  int ultimoEstado = 0;
 public void init(){};
%}

%eofval{
{return new Symbol(sym.EOF, null); }
%eofval}

%{
 private Symbol symbol(int type) {
 return new Symbol(type, yyline, yycolumn);
 }
 private Symbol symbol(int type, Object value) {
 return new Symbol(type, yyline, yycolumn, value);
 }
%}


ALPHA=[A-Za-z]
DIGITO=[0-9]
ALPHA_NUMERIC={ALPHA}|{DIGITO}
NEW_LINE=(\n|\r)
WHITE_SPACE=([\ |\t|\f])
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
st = [^\\\n\"]+ | [\\][\\] | "\\\"" | "\\\'" |"\\t"| "\\n" | "\\r" |"\\b" |"\n"
FRASE=(","|";"|":"|"-"|"_"|{ALPHA_NUMERIC})(","|";"|":"|"-"|"_"|{ALPHA_NUMERIC})*

%%
[\n] { yychar=0;}

[ \t\r\n\f] { /* ignore white space. */ }

\' { /* ignore apostrofos. */ }

 <YYINITIAL> {WHITE_SPACE}  {/*no hace nada, aumenta una columna*/yychar++; }

<YYINITIAL> {NEW_LINE}     {yychar=0; yyline=0}

<YYINITIAL>";"			{  return new Symbol(sym.PUNTOCOMA, yyline, yychar,  yytext());}
<YYINITIAL>":"			{  return new Symbol(sym.DOSPUNTOS, yyline, yychar,  yytext());}
<YYINITIAL>","			{  return new Symbol(sym.COMA, yyline, yychar,  yytext());}
<YYINITIAL>"."			{  return new Symbol(sym.PUNTO, yyline, yychar,  yytext());}
<YYINITIAL>"@"			{  return new Symbol(sym.ARROBA, yyline, yychar,  yytext());}
<YYINITIAL>"gmail"		{  return new Symbol(sym.CONST, yyline, yychar,  yytext());}
<YYINITIAL>"hotmail"		{  return new Symbol(sym.CONST1, yyline, yychar,  yytext());}
<YYINITIAL>"com"		{  return new Symbol(sym.DOM, yyline, yychar,  yytext());}
<YYINITIAL>"es"		{  return new Symbol(sym.DOM1, yyline, yychar,  yytext());}

<YYINITIAL>{FRASE}  {      return new Symbol(sym.FRASE, yyline, yychar,  yytext());}

.      { interfaz.rotular("Error lexico :"+  yytext()+" en la fila "+yyline +" y en la columna " + yychar);
                      	}